package com.myproject.myblogserver.utils;

import lombok.Data;

@Data
public class ApiResponse<T> {
    private String msg;
    private int code;
    private T data;

    // 构造器+getter+setter
    public static <T> ApiResponse<T> success(T data) {
        ApiResponse<T> response = new ApiResponse<>();
        response.setCode(0);
        response.setMsg("success");
        response.setData(data);
        return response;
    }

    public static ApiResponse<?> error(int code, String msg) {
        ApiResponse<?> response = new ApiResponse<>();
        response.setCode(code);
        response.setMsg(msg);
        return response;
    }
}
